	<%@ include file="common.jsp" %>  
	<%@ include file="loadJsAndCss.jsp" %>
<script type="text/javascript">
	$(document).ready(function() {
		enableDatepicker('startDate','dd-mm-yy');
		enableDatepicker('endDate','dd-mm-yy');
	});
	function checkVendorWiseFormValidations(){
		var i;
		var finalResult = true;
		var companySelected = false;
		var vendorCodeSelected = false;
		var error = "";
		
		if(document.forms[0].startDate.value == ""){
			error = error + "Enter Start Date" + "\n";
			finalResult = false;
		}
		if(document.forms[0].endDate.value == ""){
			error = error + "Enter End Date" + "\n";
			finalResult = false;
		}
		
		for (i=0;i<document.forms[0].companyName.length;i++) {
			if (document.forms[0].companyName[i].checked) {
				companySelected = true;
				break;
			}
		}
		if(companySelected == false){
			error = error + "Select Company" + "\n";
			finalResult = false;
		}
		for (i=0;i<document.forms[0].vendorCode.length;i++) {
			if (document.forms[0].vendorCode[i].checked) {
				vendorCodeSelected = true;
				break;
			}
		}
		if(vendorCodeSelected == false){
			error = error + "Select Vendor Code option" + "\n";
			finalResult = false;
		}
		if(error != ""){
			alert(error);
			return finalResult;
		}
		
		
		
			document.forms[0].submit();
	}
</script>

<div>
	<form:form commandName="vendorWiseReportFilter" method="POST" action="generateReport.htm" onsubmit="return false;">
		<table class="viewDetails">
			<tr class="heading">
				<td colspan="2"> Vendor Wise Purchase Report: </td>
			</tr>
			<tr class="even">
				<td> <form:label path="startDate"> Start Date: * </form:label> </td>
				<td> <form:input path="startDate" cssClass="input"/> </td>
			</tr>
			<tr class="odd">
				<td> <form:label path="endDate"> End Date: * </form:label> </td>
				<td> <form:input path="endDate" cssClass="input"/> </td>
			</tr>
			<tr class="even">
				<td> <form:label path="companyName"> Company Name: * </form:label> </td>
				<td> <form:radiobutton path="companyName" value="NMIPL"/><label class="text"> NMIPL </label> 
					 <form:radiobutton path="companyName" value="RNAIPL"/><label class="text"> RNAIPL </label>
				</td>
			</tr>
			<tr class="odd">
				<td> <form:label path="vendorCode"> Vendor Code: * </form:label> </td>
				<td> <form:radiobutton path="vendorCode" value="All"/><label class="text"> ALL </label><br>
					 <form:radiobutton path="vendorCode" value="Spec"/> Specific Code: 
					 	<form:input path="specVendorCode" cssClass="input"/> </td>
			</tr>
			<tr class="even">
				<td> <form:label path="email"> Notification email Id: </form:label> </td>
				<td> <form:input path="email" cssClass="input"/> </td>
			</tr>
			<tr class="odd" align="center">
				<td colspan="2"> <input type="button" value="Generate Report" onclick="checkVendorWiseFormValidations();"> </td>
			</tr>
		</table>
	</form:form>
</div>